From e4ba5b6ab6ce9fa742fcb34d9510e14ddbaff5b1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 30 May 2014 23:21:13 -0400 Subject: [PATCH] inspector: Go to the right tab when changing objects When going from attribute mapping to model, it makes most sense to go directly to the data tab, and when going from an action name to the owner, we want to show the actions tab. Make it so. --- gtk/inspector/prop-editor.c | 8 ++++---- gtk/inspector/prop-editor.h | 5 ++++- gtk/inspector/prop-list.c | 2 ++ gtk/inspector/window.c | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c index 213592d464..f49e7209a8 100644 --- a/gtk/inspector/prop-editor.c +++ b/gtk/inspector/prop-editor.c @@ -642,7 +642,7 @@ object_properties (GtkInspectorPropEditor *editor) g_object_get (editor->priv->object, editor->priv->name, &obj, NULL); if (G_IS_OBJECT (obj)) - g_signal_emit (editor, signals[SHOW_OBJECT], 0, obj, editor->priv->name); + g_signal_emit (editor, signals[SHOW_OBJECT], 0, obj, editor->priv->name, "properties"); } static void @@ -1092,7 +1092,7 @@ model_properties (GtkButton *button, GObject *model; model = g_object_get_data (G_OBJECT (button), "model"); - g_signal_emit (editor, signals[SHOW_OBJECT], 0, model, "model"); + g_signal_emit (editor, signals[SHOW_OBJECT], 0, model, "model", "data"); } static void @@ -1258,7 +1258,7 @@ show_action_owner (GtkButton *button, GObject *owner; owner = g_object_get_data (G_OBJECT (button), "owner"); - g_signal_emit (editor, signals[SHOW_OBJECT], 0, owner, NULL); + g_signal_emit (editor, signals[SHOW_OBJECT], 0, owner, NULL, "actions"); } static GtkWidget * @@ -1404,7 +1404,7 @@ gtk_inspector_prop_editor_class_init (GtkInspectorPropEditorClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GtkInspectorPropEditorClass, show_object), NULL, NULL, NULL, - G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_STRING); + G_TYPE_NONE, 3, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING); g_object_class_install_property (object_class, PROP_OBJECT, g_param_spec_object ("object", "Object", "The object owning the property", diff --git a/gtk/inspector/prop-editor.h b/gtk/inspector/prop-editor.h index 8febf33bab..6fef2319b4 100644 --- a/gtk/inspector/prop-editor.h +++ b/gtk/inspector/prop-editor.h @@ -41,7 +41,10 @@ typedef struct { GtkBoxClass parent; - void (*show_object) (GtkInspectorPropEditor *editor, GObject *object, const gchar *name); + void (*show_object) (GtkInspectorPropEditor *editor, + GObject *object, + const gchar *name, + const gchar *tab); } GtkInspectorPropEditorClass; diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c index 7eb03751e4..9d3b8d8b14 100644 --- a/gtk/inspector/prop-list.c +++ b/gtk/inspector/prop-list.c @@ -123,6 +123,7 @@ static void show_object (GtkInspectorPropEditor *editor, GObject *object, const gchar *name, + const gchar *tab, GtkInspectorPropList *pl) { GtkTreeIter iter; @@ -131,6 +132,7 @@ show_object (GtkInspectorPropEditor *editor, popover = gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_POPOVER); gtk_widget_hide (popover); + g_object_set_data (G_OBJECT (pl->priv->widget_tree), "next-tab", (gpointer)tab); if (gtk_inspector_widget_tree_find_object (pl->priv->widget_tree, object, &iter)) { gtk_inspector_widget_tree_select_object (pl->priv->widget_tree, object); diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index 72d1aad308..cc3b36a503 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -62,6 +62,9 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt, GtkInspectorWindow *iw) { GObject *selected = gtk_inspector_widget_tree_get_selected_object (wt); + GtkWidget *notebook; + const gchar *tab; + gint page_num; if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected)) return; @@ -77,6 +80,24 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt, gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected); gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected); + notebook = gtk_widget_get_parent (iw->prop_list); + tab = g_object_get_data (G_OBJECT (iw), "next-tab"); + if (g_strcmp0 (tab, "properties") == 0) + { + page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->prop_list); + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num); + } + else if (g_strcmp0 (tab, "data") == 0) + { + page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->data_list); + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num); + } + else if (g_strcmp0 (tab, "actions") == 0) + { + page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->actions); + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num); + } + if (GTK_IS_WIDGET (selected)) gtk_inspector_flash_widget (iw, GTK_WIDGET (selected)); } -- 2.30.2